//
//  YFNewVoicesView.m
//  YFListenStock
//
//  Created by ChinaRainbow-iOS on 2019/10/21.
//  Copyright © 2019 ChinaRainbow-iOS. All rights reserved.
//

#import "YFNewVoicesView.h"
#import "ATVideoWindowView.h"

@implementation YFNewVoicesView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self = [[NSBundle mainBundle]loadNibNamed:@"YFNewVoicesView" owner:self options:nil].lastObject;
    }
    return self;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    
    [self setUpUI];
}
-(void)setUpUI{
    self.clipsToBounds = YES;
    self.layer.cornerRadius = 3;
    self.layer.borderWidth = 0.5;
    self.layer.borderColor = HexColor(0xD7D9DB).CGColor;
    YFNewVoicePlayButtomView*yfVoice60sBottomView = [[YFNewVoicePlayButtomView alloc]initWithFrame:CGRectZero];
    [self addSubview:yfVoice60sBottomView];
    self.yfVoice60sBottomView = yfVoice60sBottomView;
    [self.yfVoice60sBottomView setUpUI];
//    yfweakify(self);
//    yfVoice60sBottomView.yfBottomBtnClick = ^(YFModelChangeType type, YFVoice60SModel *model) {
//        yfstrongify(self);
//        if (self.yfBottomBtnClick) {
//            self.yfBottomBtnClick(type, model);
//        }
//    };
    [yfVoice60sBottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
        make.height.mas_equalTo(91);
    }];
}
-(void)setIsHiddenBottomActionView:(BOOL)isHiddenBottomActionView
{
    _isHiddenBottomActionView = isHiddenBottomActionView;
    [self.yfVoice60sBottomView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.bottom.mas_equalTo(isHiddenBottomActionView ? -10:0 );
        make.height.mas_equalTo(isHiddenBottomActionView ? 46:91);
    }];
}
-(void)setModel:(YFCourseOneModel *)model{
    _model = model;
    self.yfTitleLabel.text = model.title;
    self.yfVoice60sBottomView.model = model.voiceModel;
    [self.yfPlayAndTimeBtn setTitle:[NSString stringWithFormat:@" %@  l  %@",model.play_countString,[model.created_at timeDes]] forState:0];
    [self.yfPlayAndTimeBtn setTitle:[NSString stringWithFormat:@" %@  l  %@",model.play_countString,[model.created_at timeDes]] forState:UIControlStateHighlighted];
     [self.yfShareBtn setTitle:[NSString stringWithFormat:@" %@ ",model.relay_countString] forState:UIControlStateNormal];
    if (model.voiceModel.playStatus == 1) {
        self.yfTitleLabel.textColor = [UIColor zg_D2BA99ZoneColor];
    }else{
        self.yfTitleLabel.textColor = [UIColor blackColor];
        if (model.voiceModel.is_important) {
            self.yfTitleLabel.textColor = [UIColor zgFF4F54RedColor];
        }else{
            self.yfTitleLabel.textColor = [UIColor blackColor];
        }
    }
}


@end

